package com.ti.srpglife.Screen;

import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Action;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.actions.RepeatAction;
import com.badlogic.gdx.scenes.scene2d.actions.SequenceAction;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.utils.Align;
import com.badlogic.gdx.utils.Scaling;
import com.ti.srpglife.SRPGLIFEGame;

public class SplashScreen extends AbstractScreen
{
	private Texture splashTexture;
	private TextureRegion splashTextureRegion;
	
	public SplashScreen(SRPGLIFEGame g) 
	{
		super(g);
	}

	public void render(float delta) 
	{
		super.render(delta);
	}

	public void resize(int width, int height) 
	{
		super.resize(width,height);
		stage.clear();
		
		TextureRegion splashRegion = new TextureRegion(splashTexture,0,0,512,301);
		Image splashImage = new Image(splashRegion);
		splashImage.setScaling(Scaling.stretch);
		splashImage.setAlign(Align.bottom|Align.left);
		splashImage.setWidth(width);
		splashImage.setHeight(height);
		
		splashImage.getColor().a = 0f;
		
		SequenceAction actions = new SequenceAction();
		actions.addAction(Actions.fadeIn(.75f));
		actions.addAction(Actions.delay(1.75f, Actions.fadeOut(.75f)));
		actions.addAction(Actions.run(new Runnable(){

			@Override
			public void run() {
				game.setScreen(game.getGameScreen());
			}
		
		}));
		splashImage.addAction(actions);
		
		stage.addActor(splashImage);
	}

	public void show() 
	{	
		splashTexture = new Texture("img/bg.png");
		splashTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
	}

	public void hide() {
		// TODO Auto-generated method stub

	}

	public void pause() {
		// TODO Auto-generated method stub

	}

	public void resume() {
		// TODO Auto-generated method stub

	}

	public void dispose() {
		super.dispose();
		splashTexture.dispose();
	}

}
